/* $Header: timetable.h,v 2.2 01/10/02 10:30:45 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME: timetable.h                                      */
/* ==================                                                  */
/*                                                                     */
/* Author: wikfors                                                     */
/*                                                                     */
/* COMMENT:  This file contains function prototypes for the functions  */
/*           found in the library timetable.a                          */
/*                                                                     */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

#ifndef TIMETABLE_H
#define TIMETABLE_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/


/*****************************/
/*   MACROS                  */
/*****************************/

/* use the last entry as a place to park the pointer */
/* and never execute that entry (or repetatively     */
/* execute it)                                       */
#define MAX_RTT_TYPE      ((INT32)Available_Entry-1)

/*****************************/

/*****************************/
/*   TYPEDEFS                */
/*****************************/


typedef enum {
         NULL_EVENT             = 0,  /* flag no event for an entry number */
         VALVE_1                = 1,
         VALVE_2                = 2,
         VALVE_3                = 3,
         VALVE_4                = 4,
         VALVE_5                = 5,
         VALVE_6                = 6,
         VALVE_7                = 7,
         VALVE_8                = 8,
         MULTI_VALVE            = 9,
         SIGNAL_1_DEF           = 10,
         SIGNAL_2_DEF           = 11,
         SIGNAL_1_ZERO          = 12,
         SIGNAL_2_ZERO          = 13,
         SIGNAL_1_ATTN          = 14,
         SIGNAL_2_ATTN          = 15,
         SIGNAL_1_RANGE         = 16,
         SIGNAL_2_RANGE         = 17,
         AUX_3_PRESSURE         = 18,
         AUX_4_PRESSURE         = 19,
         AUX_5_PRESSURE         = 20,
         FRNT_DET_POLARITY      = 21,
         BACK_DET_POLARITY      = 22,
         FRNT_DET_FUEL          = 23,
         BACK_DET_FUEL          = 24,
         AUX_1_TEMP             = 25,
         AUX_2_TEMP             = 26,
         FRONT_OIM1             = 27,
         FRONT_OIM2             = 28,
         FRONT_OIM3             = 29,
         FRONT_OIM4             = 30,
         BACK_OIM1              = 31,
         BACK_OIM2              = 32,
         BACK_OIM3              = 33,
         BACK_OIM4              = 34,
         STORE_SIGNAL_1_VALUE   = 35,
         STORE_SIGNAL_2_VALUE   = 36,
         SIGNAL_1_ZERO_LESS_VAL = 37,
         SIGNAL_2_ZERO_LESS_VAL = 38,
         FREEZE_SIGNAL_1_VALUE  = 39,
         FREEZE_SIGNAL_2_VALUE  = 40,
         RESUME_SIGNAL_1_VALUE  = 41,
         RESUME_SIGNAL_2_VALUE  = 42,
         FRONT_OEM5             = 43,
         FRONT_OEM7             = 44,
         BACK_OEM5              = 45,
         BACK_OEM7              = 46,
         Available_Entry        = 47   /* last entry */

       } RTT_EVENT;

typedef   void   (*TableExecutor)( U_INT32 parameter );

typedef struct
{
   TableExecutor handler;
   UI_ERR        (* const check_fcn)( RTT_EVENT type, INT32 setpt );
   SETPT         setpt_name;
   INT16         setpt_num;   /* setpoint # qualifier, e.g. Valve 1 */
} RTT_INFO;


/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

UI_ERR AddTimeTableEntry ( INT32 time, U_INT8 type, INT32 parm, U_INT8 *new_entry_num );
UI_ERR DeleteTimeTableEntry ( U_INT8 entry_num );
UI_ERR GetTimeTableEntry ( U_INT8 entry_num, INT32 *time, U_INT8 *type, INT32 *parm );
UI_ERR ChangeRunTableEntryParm ( U_INT8 entry_num, INT32 parm );
UI_ERR ChangeRunTableEntryTime ( U_INT8 entry_num, INT32 time, U_INT8 *new_entry_num );

void DeleteEntryInTable (pTIME_TABLE table, U_INT8 entry_number);
U_INT8 InsertEntryInTable (pTIME_TABLE table, U_INT32 time, U_INT8 type, INT32 parm);

UI_ERR CheckRunTableType( INT32 type );
UI_ERR CheckRunTableParam( RTT_EVENT type, INT32 param );
UI_ERR RTTCheckValveOnOff( RTT_EVENT type, INT32 param );
UI_ERR RTTCheckMultiValve( RTT_EVENT type, INT32 param );

void  ExecuteRunTimeTable ( void );
void  ResetRunTablePointer ( void );
void  UndoRunTableChanges ( void );
void  DeleteEntireTimeTable( void );
INT32 GetIuRunTableParm( RTT_EVENT type, INT32 parm );
INT32 GetDcRunTableParm( RTT_EVENT type, INT32 parm );
INT16 NumRunTableEntries( void );
INT32 MaxRunTableEntry (void);

#pragma SECTION PROG=prog

void SetUpDefaultRunTimeTable ( void );

#pragma SECTION UNDO

#endif
